package org.jeecg.modules.simulator.model.train.manager.trainmanager;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.modules.simulator.model.MetroTrain;
import org.jeecg.modules.simulator.model.train.action.ActionRecordersStatus;
import org.jeecg.modules.simulator.rooter.TrainManager;

import java.time.LocalTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 * @program: simulator-b20240918
 * @description:
 * @author: renzhg
 * @create: 2024-10-04 13:26
 **/
@Slf4j
public class StartState implements TrainState {
    private static final Logger logger = LoggerFactory.getLogger(StartState.class);

    @Override
    public void handle(TrainManager trainManager, String key, MetroTrain train, String now) {
//        logger.debug("列车id:" + train.getTrainId() + "开始运行");
        try {
            if(train.getTrainId().equals("lsAdd01")){
                logger.debug("列车id:" + train.getTrainId() + "开始运行");
            }
            trainManager.dispatchTimeTableActionRecorders(key, train, now);
            trainManager.getTrainActionRdsManager().getTrainActionRecordersMap().get(key).setStatus(ActionRecordersStatus.starting);
        } catch (Exception e) {
            logger.debug("Error dispatching timetable action recorders for train " + train.getTrainId() + ": " + e.getMessage());
        }
    }
}
